import React from 'react'
import App from './App'
import {BrowserRouter,Route,Switch} from 'react-router-dom'
// import { connect } from 'react-redux'
import storeFun from './utils/store'
import Admin from './admin'
import Home from './pages/home'
import Login from './pages/login'
import Page404 from './pages/404'
import LoginForm from './pages/form/login'
import Button from './pages/ui/button'
import BasicTable from './pages/ui/table/basicTable'
import User from './pages/rbac/user'
import Role from './pages/rbac/role'
import Menu from './pages/rbac/menu'
import Transfers from './pages/ui/transfer'
import TreeSelects from './pages/ui/treeSelect'
import Trees from './pages/ui/tree'

class Router extends React.Component{


    componentDidMount(){
        if (this.props.token===''&& storeFun.getStorage() ){
            console.log('token:'+this.props.token)

            console.log(this.props.history)

        }else {

        }
    }

    render(){

        return (
            <BrowserRouter>
                <App>
                    <Switch>

                        <Route path="/login"  component={Login}/>
                        <Route path="/" render={() =>
                            <Admin>
                                <Switch>
                                    <Route path="/admin/home" component={Home} />
                                    <Route path="/admin/form/login" component={LoginForm}/>
                                    <Route path="/admin/ui/buttions" component={Button}/>
                                    <Route path="/admin/table/basic" component={BasicTable}/>
                                    <Route path="/admin/upms/user" component={User}/>
                                    <Route path="/admin/upms/role" component={Role}/>
                                    <Route path="/admin/upms/menu" component={Menu}/>
                                    <Route path="/admin/ui/transfer" component={Transfers}/>
                                    <Route path="/admin/ui/treeSelect" component={TreeSelects}/>
                                    <Route path="/admin/ui/tree" component={Trees}/>
                                    {/*<Redirect to="/admin/home" />*/}
                                    <Route  component={Page404}/>
                                </Switch>
                            </Admin>
                        }/>
                    </Switch>
                </App>
            </BrowserRouter>
        )
    }
}
// const mapState=(state) => ({
//     token:state.getIn(['login', 'token'])
// })
//
// const mapDispatch=(dispatch) => ({
//
// })
// export default connect(mapState,mapDispatch)(Router)
export default Router